<template>
  <div class="list-page">
    <tool-bar nav="" title="jenkinsLog">
      <el-button @click="add_click()">添加</el-button>
    </tool-bar>
    <my-list
        ref="list"
        url="/dev/jenkins-log/list"
        @param="preload"
        @loaded="procData"
        :page-size="10"
        :store="true"
    >


      <el-table-column align="center" label="status" prop="status_res"></el-table-column>
      <el-table-column align="center" label="stages" prop="stages"></el-table-column>
      <el-table-column align="center" label="gitData" prop="gitData"></el-table-column>
      <el-table-column align="center" label="gitBuildInfo" prop="gitBuildInfo"></el-table-column>
      <el-table-column label="操作" align="center">
        <template v-slot="scope">
          <el-button @click="set_click(scope.row)" size="small" round>
            设置状态
          </el-button>
          <el-button type="warning" plain round @click="delete_click(scope.row)" size="small">
            删除
          </el-button>
        </template>
      </el-table-column>
      <template #query="scope">
      </template>
    </my-list>
  </div>
</template>

<script setup>
/**
 * Created by CodeGenerator at 2022-02-20 12:46:33
 */



//定义 vue2的this,当前组件
const $self = getCurrentInstance();

//定义 $attrs
const $attrs = useAttrs();



//定义data
const $data = reactive({
    JenkinsJobStatusEnum: jv.enum.JenkinsJobStatusEnum.getData(),
});


const $props = defineProps({

});





const list = ref();

//定义事件
const $emit = defineEmits(["update:modelValue","loaded"]);



const preload = function(param) {
//添加查询参数，修改分页参数等。
//param.type = jv.$route.params.type
};
const procData = function(res) {
    res.data.data.forEach(it => {
//如果是组合实体，设置 it.id=...
        jv.enum.JenkinsJobStatusEnum.fillRes(it, "status");
    });
};
const loadData = function(pageNumber) {
    list.value.loadData(pageNumber);
};
const add_click = function() {
    jv.$router.push("/dev/jenkins-log/add")
};
const edit_click = function(row) {
//记录上次点击行
    var rowId = row.id;
    list.value.setLastRow(row);
    jv.$router.push("/dev/jenkins-log/edit/" + rowId)
};
const delete_click = async function(row) {
    var rowId = row.id,rowName = row.name;
    await jv.confirm('确认删除 ' + rowName + ' 吗？');
    var res = await jv.$http.post("/dev/jenkins-log/delete/" + rowId)
    loadData();
};
const set_click = function(row) {
//设置事件
    var rowId = row.id;
};

</script>